(define (make-account balance password)
  (define (withdraw amount)
    (if (>= balance amount)
        (begin (set! balance (- balance amount))
               balance)
        "Insufficient funds"))
  (define (deposit amount)
    (set! balance (+ balance amount)))
  (define (call-the-cops)
    (error "Call the cops"))
  (let ((fail-count 0))
    (define (dispatch p m)
      (if (not (eq? p password))
          (begin (set! fail-count (+ 1 fail-count))
                 (if (= fail-count 7)
                     (call-the-cops)
                     (lambda (amount) (error "Incorrect password"))))
          (begin (set! fail-count 0)
                 (cond ((eq? m 'withdraw) withdraw)
                       ((eq? m 'deposit) deposit)
                       (else (error "Unkown request -- MAKE-ACCOUNT"
                                    m))))))
    dispatch))
